#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#ifndef _SORT_TEST_H
#define _SORT_TEST_H

#define SMALL_DATA_N 5000
#define BIG_DATA_N   1000000

__attribute__((constructors))
void __init_Rand__() {
    printf("init rand\n");
    srand(time(0));
}

bool check(int *arr, int l, int r){
	for(int i = l + 1; i < r; i++){
		if(arr[i] < arr[i - 1]) return false;
	}
	return true;
}

#define swap(a, b){\
    __typeof(a) __c = (a);\
    (a) = (b);\
    (b) = __c;\
}

int *getRandData(int n){
    int *arr = (int *)malloc(sizeof(int) * n);
    for(int i = 0; i < n; i++) arr[i] = rand() % 10000;
    return arr;
}

#define TEST(func, arr, n){\
	printf("Test %s : ", #func);\
	int *tmp =(int *)malloc(sizeof(int) * n);\
	memcpy(tmp, arr, sizeof(int) * n);\
	long long b = clock();\
	func(tmp, 0, n);\
	long long e = clock();\
	if(check(tmp, 0, n)){\
		printf("OK\t");\
	}else{\
		printf("Failed\t");\
	}\
	printf("%d items %lld ms\n", n, (e - b ) * 1000 / CLOCKS_PER_SEC);\
    free(tmp);\
}

#endif